home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 April
/
Macworld (1999-04).dmg
/
Serious Software
/
SiteCam 3.0 demo
/
Extras
/
Sample AppleScripts
/
FTP Scripts
/
PPP Fetch sample
< prev
Wrap
Text File
|
1997-11-11
|
4KB
|
96 lines
-- This is a SiteCam post-process script to FTP the last image
-- (Image.jpg) to a remote FTP location and saves it as "current.jpg".
-- This document should be viewed and edited using "Script Editor".
-- This script starts and terminates a PPP connection if not already
-- connected
-- The FTP portion of the script uses a two step process to minimize
-- the time that a image is unavailable to the http server.
-- Step 1: Get the right PPP
-- Verify that you have the latest Apple PPP
-- Install and make sure that "PPP Commands" is in your
-- "System Folder:Extensions:Scripting Additions" folder.
-- To test your PPP, create a new script and type "PPP Connect"
-- and hit "Run."
-- If you're already connected, you'll get an error. Next, delete
-- that and type "PPP Disconnect" and hit "Run."
--
-- If your Fetch program is not named "Fetch", either rename it
-- or change the script to its actual file name (e.g. Fetch 3.0)
--
-- Step 2:
-- Open this document from ScriptEditor- save it as "MyFTP Script"
-- Create a Ram Disk for added efficiency using the "Memory" control
-- panel. (Or rename file path to suit your needs)
-- Put an alias of Fetch 3.0.1 in your "Startup Items" folder in your
-- System Folder. If you have an older version, please upgrade.
-- Reboot to activate Ram Disk and start Fetch.
-- Edit the script below, modifying the host, userID, password, and
-- file names as needed. They have been marked with xxxxxx
-- Step 3:
-- Create a SiteCam document with the following settings
-- Set type to jpeg (already default)
-- Set number of pictures to save to 1
-- Set image destination folder to your Ram Disk
-- set file name to Image
-- Do not set your post process proc yet.
-- Save your SiteCam document in your System Folder:Startup items folder.
-- Do a command-T (take picture now) to take the first picture.
-- Next: Go to this script editor document and try running the script.
-- If all goes well, current.jpg should exist on your remote FTP server.
-- Debug as needed. When working, Quit Script Editor or close
-- "MyFTP Script".
-- From SiteCam, Set Post process script to this document to
-- "MyFTP Script"
with timeout of 1000 seconds
try
-- Find status of PPP connection and store in a variable "origState"
set origState to PPP status
-- If not connected, connect to your ISP
if (state of origState is not "Connected") then
PPP connect
end if
-- If we're connected, do the FTP part
if (state of (PPP status) is "Connected") then
-- Save the last file saved to a remote FTP directory.
-- Change all the xxxx's to your own values.
-- In Fetch--Under Customize, Preferences, Misc. "Show Sign-up dialog at startup" should be unchecked.
-- Get location of the last file saved.
tell application "SiteCam"
set lastFileSaved to last image file of active document
end tell
tell application "Fetch 3.0.3"
make new transfer window with properties {hostname:"ftp.xxxxxx.com", userid:"xxxxxxUserName", password:"xxxxxxPassword", path:""}
put into transfer window "ftp.xxxxxx.com" item alias lastFileSaved text format Raw Data binary format Raw Data
close front window saving no -- we avoid any dialogs by adding "saving no"
end tell
else
-- signal FTP error
-- change this to some error, or take out beep if it bugs you.
beep
beep
end if
PPP disconnect
on error errMsg number errNum
-- signal PPP or other error
-- change this to some error, or take out beep if it bugs you.
beep
end try
end timeout